#!/bin/bash

#csi_cephfs_sc="csi-cephfs-sc-es"
claim_array=("")
for claim in `kubectl get pv -n pcm | awk '($7=="csi-cephfs-sc-es"){print $6}' | awk -F"/" '{print $2}'`
do
	claim_array[${#claim_array[@]}]=$claim
done
#echo ${claim_array[*]}
capacity_array=("")
for capacity in `kubectl get pv -n pcm | awk '($7=="csi-cephfs-sc-es"){print $2}'`
do
	capacity_array[${#capacity_array[@]}]=$capacity
done

policy_array=("")
for policy in `kubectl get pv -n pcm | awk '($7=="csi-cephfs-sc-es"){print $4}'`
do
	policy_array[${#policy_array[@]}]=$policy
done

cephfs_root_dir="/cephfs_root"
cephfs_real_dir=""
idx=1
for subvolumePath in `kubectl describe pv $(kubectl get pv -n pcm | awk '($7=="csi-cephfs-sc-es"){print $1}') -n pcm | grep subvolumePath | awk -F"=/" '{print $2}'`
do
	cephfs_real_dir=$cephfs_root_dir/$subvolumePath
	#echo $cephfs_real_dir
	echo -e "${claim_array[$idx]} [${capacity_array[$idx]}, ${policy_array[$idx]}]\t\c"
	ssh root@ceph-node1 du -sh $cephfs_real_dir
	idx=$(($idx+1))
done